package com.goldgov.code.template.point.impl;

import com.goldgov.code.template.point.CodePoint;

public class InterfaceMethodCodePoint extends CodePoint{
	
	private String[] annotation;
	
	private final String methodName;
	private String returnClass;
	private String args;

	public InterfaceMethodCodePoint(String methodName) {
		this(methodName, "void", null);
	}
	
	public InterfaceMethodCodePoint(String methodName,String args) {
		this(methodName, "void", args);
	}
	
	public InterfaceMethodCodePoint(String methodName,String returnClass,String args) {
		super("JAVA:INTERFACE");
		this.methodName = methodName;
		this.returnClass = returnClass;
		this.args = args;
	}
	
	@Override
	public String getCodes() {
		StringBuilder strBuilder = new StringBuilder();
		if(annotation != null) {
			for (String anno : annotation) {
				strBuilder.append("    " + anno + "\r\n");
			}
		}
		strBuilder.append("    " + returnClass + " " + methodName + "(" + (args == null ? "" : args.toString()) + ");\r\n");
		return strBuilder.toString();
	}


	public void setAnnotation(String... annotation) {
		this.annotation = annotation;
	}
	
	public void setAnnotation(Class<?>... annoClass) {
		this.annotation = new String[annoClass.length];
		for (int i = 0; i < annoClass.length; i++) {
			this.annotation[i] = "@" + annoClass[i].getSimpleName();
		}
	}

}
